﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<我的工作日志列表>
-- =============================================
CREATE PROCEDURE [dbo].[proc_WorkLog_My_GetList]
(
	@UserName NVARCHAR(50),
	@LogType INT,
	@StartIndex int,
	@EndIndex int
)
AS
BEGIN
If @LogType=1
	Begin
		;WITH List As(Select ROW_NUMBER() OVER (Order BY CreateTime Desc) AS Row,
			id,
			GID, 
			Title, 
			[Content], 
			CreateTime, 
			EditTime, 
			UserName, 
			Name, 
			CompanyId,
			DepId, 
			LogType
			FROM WorkLog
			WHERE UserName=@UserName AND LogType In(1,3)
		)
		Select *,(Select Count(0) From list) As RecordCount From list Where Row Between @StartIndex and @EndIndex Order By Row
	End
Else
	Begin
		;WITH List As(Select ROW_NUMBER() OVER (Order BY CreateTime Desc) AS Row,
			id,
			GID, 
			Title, 
			[Content], 
			CreateTime, 
			EditTime, 
			UserName, 
			Name, 
			CompanyId,
			DepId, 
			LogType
			FROM WorkLog
			WHERE UserName=@UserName AND LogType=@LogType
		)
		Select *,(Select Count(0) From list) As RecordCount From list Where Row Between @StartIndex and @EndIndex Order By Row
	End
END
